import { h } from 'vue'
import { RouterView } from 'vue-router'
//渲染三级路由出口routerview
const RouterViewPage = {
  name: 'RouterViewPage',
  render: () => h(RouterView),
}

//首页子集路由
const indexRoutes = [
  {
    path: 'welcome',
    name: 'index-welcome',
    meta: {
      title: '首页',
      icon: 'home-outlined',
      hidden: false,
      level: 3,
      id: 'index-welcome',
      parentId: 'index',
    },
    component: () => import('@/views/index/Welcome.vue'),
  },
  {
    path: 'personal',
    name: 'index-personal',
    meta: {
      title: '个人中心',
      icon: 'UserOutlined',
      hidden: true,
      level: 3,
      id: 'index-personal',
      parentId: 'index',
    },
    component: () => import('@/views/index/Personal.vue'),
  },
  {
    path: 'setting',
    name: 'index-setting',
    meta: {
      title: '个人设置',
      icon: 'SettingOutlined',
      hidden: true,
      level: 3,
      id: 'index-setting',
      parentId: 'index',
    },
    component: () => import('@/views/index/Setting.vue'),
  },
]
//设备管理子集路由
const iotRoutes = [
  {
    path: 'template',
    name: 'iot-template',
    meta: {
      title: '通用物模型',
      icon: 'CompassOutlined',
      hidden: false,
      level: 3,
      id: 'iot-template',
      parentId: 'iot',
    },
    component: () => import('@/views/iot/Template.vue'),
  },
  {
    path: 'category',
    name: 'iot-category',
    meta: {
      title: '产品分类',
      icon: 'ClusterOutlined',
      hidden: false,
      level: 3,
      id: 'iot-category',
      parentId: 'iot',
    },
    component: () => import('@/views/iot/Category.vue'),
  },
  {
    path: 'product',
    name: 'iot-product',
    meta: {
      title: '产品管理',
      icon: 'DisconnectOutlined',
      hidden: false,
      level: 3,
      id: 'iot-product',
      parentId: 'iot',
    },
    component: () => import('@/views/iot/Product.vue'),
  },
]
//系统管理
const systemRoutes = [
  {
    path: 'user',
    name: 'system-user',
    meta: {
      title: '用户管理',
      icon: 'UsergroupDeleteOutlined',
      hidden: false,
      level: 3,
      id: 'system-user',
      parentId: 'system',
    },
    component: () => import('@/views/system/User.vue'),
  },
  {
    path: 'menu',
    name: 'system-menu',
    meta: {
      title: '菜单管理',
      icon: 'MenuOutlined',
      hidden: false,
      level: 3,
      id: 'system-menu',
      parentId: 'system',
    },
    component: () => import('@/views/system/Menu.vue'),
  },
]

/* 主页二级路由 */
const childRoutes = [
  {
    path: '/index',
    name: 'index',
    meta: {
      title: '',
      icon: '',
      hidden: true,
      level: 2,
      id: 'index',
      parentId: 'home',
    },
    component: RouterViewPage,
    redirect: '/index/welcome',
    children: indexRoutes,
  },
  {
    path: '/iot',
    name: 'iot',
    meta: {
      title: '设备管理',
      icon: 'DashboardOutlined',
      hidden: false,
      level: 2,
      id: 'iot',
      parentId: 'home',
    },
    component: RouterViewPage,
    redirect: '/iot/category',
    children: iotRoutes,
  },
  {
    path: '/system',
    name: 'system',
    meta: {
      title: '系统管理',
      icon: 'AppstoreOutlined',
      hidden: false,
      level: 2,
      id: 'system',
      parentId: 'home',
    },
    component: RouterViewPage,
    redirect: '/system/user',
    children: systemRoutes,
  },
]
export default childRoutes
